/**
 * col_img
 */
layui.define(['YunjColsTemplet','jquery','yunj'], function (exports) {

    let YunjColsTemplet = layui.YunjColsTemplet;
    let doc = document;
    let $ = layui.jquery;

    class YunjColsTempletImg extends YunjColsTemplet{

        constructor(options) {
            super(options);
        }

        layout(){
            let that=this;
            return `{{# 
                         let src = d.${that.key};
                     }}
                    {{#  if(d.is_export){  }}
                    {{ src }}
                    {{#  }else{  }}
                    <img class="table-row-img" src="{{ src?src:'${that.args.default}' }}" alt="" title="点击预览">
                    {{#  }  }}`;
        }

        defineExtraEventBind(){
            let that=this;

            $(doc).on('click','.table-row-img',function () {
                let src=$(this).attr('src');
                if(!src) return false;
                yunj.previewImg(src);
            });
        }

    }

    exports('col_img', YunjColsTempletImg);
});